
import random

class codebook:
  region_list =  region_list = ['a', 'b', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'w', 'x', 'y', 'z', '1',
                 '2', '7', '8', '9', '0', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
                 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%',
                 '^', '&', '*', '(',
                 ')', '+', '-', '~', ':', ';', '<', '>', '?', '[', ']', '{', '}', 'α', 'β', 'γ', 'δ', 'ε', '3', '4',
                 '5', '6', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'r', 's', 't', 'u', 'v',
                 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω']
  def shuffle_code(self):

    region_list = codebook.region_list

    print('原顺序：', region_list)

    shuffle_index = [i for i in range(len(region_list))]

    random.shuffle(shuffle_index)

    shuffle_list = []

    for i in shuffle_index:
      shuffle_list.append(region_list[i])

    print('打乱顺序：', shuffle_list)

    return shuffle_list

  def addpwd_phone_num(self,phone_num):

    shuffle_list = self.shuffle_code()

    print(shuffle_list)

    print('源号码：', phone_num)

    addpwd_num = []

    for ch in phone_num:
      temp = int(ch)
      addpwd_num.append(shuffle_list[temp])

    print('加密后：', ''.join(addpwd_num))

    return shuffle_list

def unlock_pwd(lock_phone_num,shuffle_list):

  for i in lock_phone_num:
    print (shuffle_list.index(i),end='')

if __name__ == '__main__':

  tem=codebook()

  phone_num = '15637146928'

  # tem.shuffle_code()#更新密码本

  shuffle_list=tem.addpwd_phone_num(phone_num)

########################################################下边是解密用的###############################

  shuffle_list = ['ω', 't', 'I', 'g', 'η', '}', 'κ', 'n', '@', 'ζ', '~', 'X', 'ρ', 'r', '{', 'z', '?', 'U', '3', 'ξ', 'P', 'G', 'q', '^', '7', 's', 'D', 'E', ')', 'H', 'm', 'u', '-', '#', '<', 'ο', '*', 'Q', 'υ', 'O', ':', '>', 'A', 'k', 'W', 'B', 'p', 'e', '%', 'ε', 'μ', 'f', 'ν', 'α', 'N', '0', '6', '[', '$', 'σ', '+', '9', 'V', 'y', 'λ', 'R', 'j', 'ι', ']', 'x', 'β', 'M', 'χ', 'Y', '!', 'c', 'ψ', 'J', 'i', 'T', 'K', ';', '1', 'φ', '2', 'τ', 'h', '8', 'v', 'L', 'γ', 'Z', 'b', '5', 'F', 'w', 'd', 'a', '4', 'C', '&', 'π', 'o', 'l', 'δ', '(', 'S', 'θ']

  unlock_pwd('t}κgnttκ@κ@',shuffle_list)

  # print(shuffle_list.index('I'))

  # addpwd_phone_num(phone_num)